package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.OrderAirportservice;
import com.ktgj.service.service.IOrderAirportserviceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机场服务订单Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/orderairportservice")
public class OrderAirportserviceController extends BaseController
{
    @Autowired
    private IOrderAirportserviceService orderAirportserviceService;

    /**
     * 查询机场服务订单列表
     */
    @PreAuthorize(hasPermi = "service:airportservice:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderAirportservice orderAirportservice)
    {
        startPage();
        List<OrderAirportservice> list = orderAirportserviceService.selectOrderAirportserviceList(orderAirportservice);
        return getDataTable(list);
    }

    /**
     * 导出机场服务订单列表
     */
    @PreAuthorize(hasPermi = "service:airportservice:export")
    @Log(title = "机场服务订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderAirportservice orderAirportservice) throws IOException
    {
        List<OrderAirportservice> list = orderAirportserviceService.selectOrderAirportserviceList(orderAirportservice);
        ExcelUtil<OrderAirportservice> util = new ExcelUtil<OrderAirportservice>(OrderAirportservice.class);
        util.exportExcel(response, list, "机场服务订单数据");
    }

    /**
     * 获取机场服务订单详细信息
     */
    @PreAuthorize(hasPermi = "service:airportservice:query")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return AjaxResult.success(orderAirportserviceService.selectOrderAirportserviceById(orderId));
    }

    /**
     * 新增机场服务订单*/
    @PreAuthorize(hasPermi = "service:airportservice:add")
    @Log(title = "机场服务订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderAirportservice orderAirportservice)
    {
        return toAjax(orderAirportserviceService.insertOrderAirportservice(orderAirportservice));
    }

    /**
     * 修改机场服务订单*/
    @PreAuthorize(hasPermi = "service:airportservice:edit")
    @Log(title = "机场服务订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderAirportservice orderAirportservice)
    {
        return toAjax(orderAirportserviceService.updateOrderAirportservice(orderAirportservice));
    }

    /**
     * 删除机场服务订单*/
    @PreAuthorize(hasPermi = "service:airportservice:remove")
    @Log(title = "机场服务订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(orderAirportserviceService.deleteOrderAirportserviceByIds(orderIds));
    }
}
